# Author    :Dun_Hz
# Time      :2024/3/18 11:32
# 利用栈实现括号匹配问题
from Stack import Stack

def brace_match(s):
    match = {'}':'{', ']':'[', ')':'('}
    stack = Stack()
    for ch in s:        # 遍历传入的每一个值
        if ch in ['(','[','{']:
            stack.push(ch)
        else:       # ch in [')',']','}']
            if stack.isEmpty():
                return False
            elif stack.peek()==match[ch]:
                stack.pop()
            else:
                return False
    if stack.isEmpty():
        return True
    else:
        return False

print(brace_match('[{()}(){()}[]({}){}]'))